<template>
  <div>
    <el-row>
      <el-col :span="24">
        <h1>订单管理</h1>
      </el-col>
    </el-row>
    <el-row >
      <el-col :span="24">
        <el-table
            :data="tableData"
            style="width: 100%"
            height="250">
          <el-table-column
              prop="username"
              label="用户"
              width="120">
          </el-table-column>
          <el-table-column
              prop="cinemaName"
              label="影院"
              width="120">
          </el-table-column>
          <el-table-column
              prop="lobbyName"
              label="影厅"
              width="120">
          </el-table-column>
          <el-table-column
              prop="movieName"
              label="电影"
              width="150">
          </el-table-column>
          <el-table-column
              prop="orderNumber"
              label="订单号"
              width="180">
          </el-table-column>
          <el-table-column
              prop="orderTime"
              label="订单时间"
              width="300">
          </el-table-column>
          <el-table-column
              prop="payment"
              label="支付方式"
              width="120">
          </el-table-column>
          <el-table-column
              prop="money"
              label="金额"
              width="120">
          </el-table-column>
          <el-table-column
              prop="state"
              label="订单状态"
              width="120">
          </el-table-column>
          <el-table-column
              fixed="right"
              label="操作"
              width="100">
            <template slot-scope="scope">
              <el-button @click="handleClick(scope.row)" type="text" size="small">查看</el-button>
            </template>
          </el-table-column>
        </el-table>
        <el-pagination
            background
            layout="prev, pager, next"
            :total="total"
            :page-size="pageSize"
            @current-change="handlePage"
            :current-page.sync="page">
        </el-pagination>
      </el-col>
    </el-row>
  </div>
</template>

<script>
export default {
  name: "OrdersListView",
  data() {
    return {
      cinemaList: [],
      cinemaId: '',
      lobbyList: [],
      lobbyId: '',
      userId: this.$route.query.userId,
      screeningId: this.$route.query.screeningId,
      tableData: [],
      total: 0,
      page: 1,
      pageSize: 0
    }
  },
  created() {
    this.handleList()
  },
  methods: {
    handleList() {
      this.axios.get("manage/order/list",{params: {
          pageNum: this.page,
          userId: this.userId,
          screeningId: this.screeningId,
          cinemaId: this.cinemaId,
          lobbyId: this.lobbyId
        }}).then(response => {
        if (response.data.code == 200) {
          console.log(response)
          this.tableData = response.data.data.list
          this.cinemaList = response.data.data.cinemaList
          this.pageSize = response.data.data.pageSize
          this.total = response.data.data.total
        }
      })
    },
    handleClick(order){
      this.$router.push({path:"/orders/ordersDetailsList",query: {
          order:order
        }})
    },
    handlePage(){

    }
  }
}
</script>

<style scoped>

</style>